package ms.jasim.console;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;

public class ConsoleGUI {

	protected Shell shell;

	/**
	 * Launch the application
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			ConsoleGUI window = new ConsoleGUI();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window
	 */
	public void open() {
		final Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
	}

	/**
	 * Create contents of the window
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setSize(535, 402);
		shell.setText("Jasim Console");

		final ToolBar toolBar = new ToolBar(shell, SWT.BORDER);
		toolBar.setBounds(0, 0, 519, 25);

		final ToolItem newItemToolItem = new ToolItem(toolBar, SWT.PUSH);
		newItemToolItem.setText("Connect");

		final Menu menu = new Menu(shell, SWT.BAR);
		shell.setMenuBar(menu);

		final MenuItem systemMenuItem = new MenuItem(menu, SWT.CASCADE);
		systemMenuItem.setText("&System");

		final Menu systemSubMenu = new Menu(systemMenuItem);
		systemMenuItem.setMenu(systemSubMenu);

		final MenuItem connectMenuItem = new MenuItem(systemSubMenu, SWT.NONE);
		connectMenuItem.setText("&Connect...");

		final MenuItem disconnectMenuItem = new MenuItem(systemSubMenu, SWT.NONE);
		disconnectMenuItem.setText("&Disconnect");

		new MenuItem(systemSubMenu, SWT.SEPARATOR);

		final MenuItem refreshMenuItem = new MenuItem(systemSubMenu, SWT.NONE);
		refreshMenuItem.setText("&Refresh");

		new MenuItem(systemSubMenu, SWT.SEPARATOR);

		final MenuItem exitMenuItem = new MenuItem(systemSubMenu, SWT.NONE);
		exitMenuItem.setAccelerator(SWT.ALT | SWT.F4);
		exitMenuItem.setText("&Exit");

		final MenuItem windowsMenuItem = new MenuItem(menu, SWT.CASCADE);
		windowsMenuItem.setText("Windows");

		final Menu menu_2 = new Menu(windowsMenuItem);
		windowsMenuItem.setMenu(menu_2);

		final MenuItem showAgentsTimeMenuItem = new MenuItem(menu_2, SWT.CHECK);
		showAgentsTimeMenuItem.setText("Show Agents Time Line");
		//
	}

}
